package huoye.shops.guidance.presenter;


import android.os.CountDownTimer;

import com.codeideology.android.utils.StringUtils;

import huoye.shops.MainActivity;
import huoye.shops.R;
import huoye.shops.base.BasePresenter;
import huoye.shops.base.MineBaseJsonRequestCallback;
import huoye.shops.base.UserManager;
import huoye.shops.common.model.SMSCoder;
import huoye.shops.guidance.view.ILaunchView;
import huoye.shops.huoye.user.model.UpdateInfo;
import huoye.shops.huoye.user.model.User;
import huoye.shops.huoye.user.network.UserService;
import huoye.shops.huoye.user.view.ILoginView;


/**
 * Created by uesr on 2017/7/19.
 */

public class LaunchPresenter extends BasePresenter<ILaunchView> {

    private UserService mService;




    //检测升级
    public void checkUpdate() {
            mService.checkUpdate(new MineBaseJsonRequestCallback<UpdateInfo>(UpdateInfo.class) {

                //请求成功
                @Override
                public void onSuccess(UpdateInfo updateInfo) {
                    super.onSuccess(updateInfo);
                    view.onCheckUpdate(updateInfo);
                }

                //网络请求失败
                @Override
                public void onFailure(String msg, String code, Throwable e) {
                    super.onFailure(msg, code, e);
                    view.makeToast(msg);
                }

                //加载失败
                @Override
                public void onNetworkFail() {
                    super.onNetworkFail();
                    view.onNetworkFail();
                }

                //加载结束
                @Override
                public void onFinish() {
                    super.onFinish();
                    view.hideProcessingIndicator();
                }

            });


    }














    /**
     * 检查升级
     *

     */
  /*  public void getHelpList(final OnHelpListListener listener) {
        if (UserManager.getManager().getUser() != null) {
            String timestamp = String.valueOf(TimeUtil.getCurrentMillis());
            HttpManager.getManager().getService().getHelpList(timestamp, CommUtil.getSign(Constant.HELP_LIST, timestamp),
                    UserManager.getManager().getUser().user_token)
                    .enqueue(new Callback<HelpCenterInfo>() {
                        @Override
                        public void onResponse(Call<HelpCenterInfo> call, Response<HelpCenterInfo> response) {
                            if (response.body() != null && response.body().status == 200) {
                                if (response.body().data != null) {
                                    listener.onHelpListSuccess(response.body());
                                } else {
                                    listener.onHelpListFailed(response.body().info);
                                }
                            } else {
                                listener.onNetworkError();
                            }
                        }

                        @Override
                        public void onFailure(Call<HelpCenterInfo> call, Throwable t) {
                            listener.onNetworkError();
                        }
                    });
        }
    }
*/

    @Override
    public void onStart() {
        mService = new UserService();

    }




}
